<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>axios</title>
</head>

<body>
    <script type="text/javascript" src="js/axios.js"></script>
    <script type="text/javascript">
        /**
         * axios 请求拦截器
         */
        axios.interceptors.request.use(function (config) {
            console.log(config);
            config.headers.mytoken = 'my-tokens';
            return config;
        }, function (err) {
            console.log(err);
        })

        /**
         * axios 响应拦截器
         */
        axios.interceptors.response.use(function (res) {
            console.log(res);
            var data = res.data;
            return data;
        }, function (err) {
            console.log(err);
        });

        // 接受请求
        axios.get('http://localhost:3000/adata').then(function (res) {
            console.log(res);
        });
    </script>
</body>

</html>